package com.inxedu.os.edu.service.course.impl;

import com.inxedu.os.edu.dao.EduCourseMapper;
import com.inxedu.os.edu.dao.EduCourseNewMapper;
import com.inxedu.os.edu.dao.SysSubjectMapper;
import com.inxedu.os.edu.pojo.*;
import com.inxedu.os.edu.service.course.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class CourseServiceImpl implements CourseService {
    @Autowired
    private EduCourseMapper eduCourseMapper;
    @Autowired
    private EduCourseNewMapper eduCourseNewMapper;
    @Autowired
    private SysSubjectMapper sysSubjectMapper;
    @Override
    public int addCourse(EduCourse eduCourse) {
        int i = eduCourseMapper.insertSelective(eduCourse);

        return i;
    }

    @Override
    public List<Map<String,Object>> selectCourseList() {
        EduCourseExample eduCourse=new EduCourseExample();
        /* return eduCourseMapper.selectByExample(eduCourse);*/

        List<Map<String, Object>> maps = eduCourseNewMapper.selectNewExample(eduCourse);
        return  maps;
    }

    @Override
    public int deleteCourseList(long courseId) {


        return eduCourseNewMapper.deleteCourseByPrimaryKey(courseId);
    }

    @Override
    public int updateCourseList(long courseId) {
        EduCourse eduCourse=new EduCourse();
        eduCourse.setCourseId(courseId);

        return eduCourseMapper.updateByPrimaryKey(eduCourse);
    }

    @Override
    public Map<String,Object> queryCourseById(long courseId) {

        Map<String, Object> stringObjectMap = eduCourseNewMapper.selectNewCourseExample(courseId);
        return stringObjectMap;
    }

    @Override
    public List<Map<String, Object>> selectByName( EduCourserNew queryCourse) {
        return eduCourseNewMapper.selectByName(queryCourse);
    }
//查询专业
   @Override
   public List<Map<String,Object>> selectSybject(QuerySubject querySubject) {
       SysSubjectExample sysSubjectExample=new SysSubjectExample();

        List<Map<String,Object>> sysSubjects = sysSubjectMapper.selectByExamplesssss(sysSubjectExample);
        return sysSubjects;
   }

    @Override
    public int createCourse(EduCourse eduCourse) {

        return  eduCourseNewMapper.addCourse(eduCourse);
    }
    //查询讲师
    @Override
    public List<EduTeacher> queryTeacherList() {
        List<EduTeacher> eduTeachers = eduCourseNewMapper.queryTeacherList();
        return eduTeachers;
    }

    @Override
    public int goUpdateCourse(EduCourse eduCourse) {
        eduCourseNewMapper.goUpdateCourse(eduCourse);
        return 0;
    }

    @Override
    public int deleteCourseTeacher(Long courseId) {
        return 0;
    }

    @Override
    public int addCouseTeacher(String toString) {
        return 0;
    }


}
